<?php

class Activity_Controller_Browse_Ajax_Like extends Nuo_Controller
{
	function execute($request)
	{
		$table = Nuo::getTable('activity/like');

		$type = $request -> getParam('type');

		$id = $request -> getParam('id');

		$object = Nuo::getItem($type, $id);

		$viewer = Nuo::getUser();

		$result = Nuo::getApi('activity/like') -> toggleLike($object, $viewer);

		$object -> isLiked = $result;

		return array(
			'html_id' => $object -> getHtmlId(),
			'data_type' => $type,
			'data_id' => $id,
			'success' => 1,
			'result' => 'activity/like',
			'like_count' => $object -> like_count,
			'html' => Intl::__($result ? 'Unlike' : 'Like'),
			'like_html' => $object -> getLikeMessage(),
		);
	}

}
